#include <cstdio>
#include <queue>



/**
 * 报数
 * @return 
 */
int main() {
	std::queue<int> q;

	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		q.push(i);
	}

	while(q.size() > 1) {
		q.push(q.front());
		q.pop();
		q.push(q.front());
		q.pop();

		q.pop();
	}

	printf("%d\n", q.front());

	return 0;
}